package com.debao.web.controller.debao;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.debao.common.annotation.Log;
import com.debao.common.core.controller.BaseController;
import com.debao.common.core.domain.AjaxResult;
import com.debao.common.enums.BusinessType;
import com.debao.system.domain.StadiumTable;
import com.debao.system.service.IStadiumTableService;
import com.debao.common.utils.poi.ExcelUtil;
import com.debao.common.core.page.TableDataInfo;

/**
 * 场馆的台桌Controller
 * 
 * @author DeBao
 * @date 2024-06-13
 */
@RestController
@RequestMapping("/debao/table")
public class StadiumTableController extends BaseController
{
    @Autowired
    private IStadiumTableService stadiumTableService;

    /**
     * 查询场馆的台桌列表
     */
    @PreAuthorize("@ss.hasPermi('debao:table:list')")
    @GetMapping("/list")
    public TableDataInfo list(StadiumTable stadiumTable)
    {
        startPage();
        List<StadiumTable> list = stadiumTableService.selectStadiumTableList(stadiumTable);
        return getDataTable(list);
    }

    /**
     * 导出场馆的台桌列表
     */
    @PreAuthorize("@ss.hasPermi('debao:table:export')")
    @Log(title = "场馆的台桌", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StadiumTable stadiumTable)
    {
        List<StadiumTable> list = stadiumTableService.selectStadiumTableList(stadiumTable);
        ExcelUtil<StadiumTable> util = new ExcelUtil<StadiumTable>(StadiumTable.class);
        util.exportExcel(response, list, "场馆的台桌数据");
    }

    /**
     * 获取场馆的台桌详细信息
     */
    @PreAuthorize("@ss.hasPermi('debao:table:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(stadiumTableService.selectStadiumTableById(id));
    }

    /**
     * 新增场馆的台桌
     */
    @PreAuthorize("@ss.hasPermi('debao:table:add')")
    @Log(title = "场馆的台桌", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StadiumTable stadiumTable)
    {
        return toAjax(stadiumTableService.insertStadiumTable(stadiumTable));
    }

    /**
     * 修改场馆的台桌
     */
    @PreAuthorize("@ss.hasPermi('debao:table:edit')")
    @Log(title = "场馆的台桌", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StadiumTable stadiumTable)
    {
        return toAjax(stadiumTableService.updateStadiumTable(stadiumTable));
    }

    /**
     * 删除场馆的台桌
     */
    @PreAuthorize("@ss.hasPermi('debao:table:remove')")
    @Log(title = "场馆的台桌", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stadiumTableService.deleteStadiumTableByIds(ids));
    }
}
